
class Solution:
    def findPeakElement(self, nums: list[int]) -> int:
        if nums[0]>nums[1]:
            return 0
        if nums[-1]>nums[-2]:
            return len(nums)-1
        return self.plus(nums,0,len(nums)-1)

    def plus(self, nums, st, end):
        middle=int((st+end)/2)
        if nums[middle]<nums[st]:
            return self.plus(nums,st,middle)
        if nums[middle]<nums[end]:
            return self.plus(nums,middle,end)


